package com.gpay.erp.web.util;

import com.google.gson.Gson;
import org.springframework.stereotype.Controller;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Created by Administrator on 2015/4/27 0027.
 */
@Controller
public class WebUtil {

	public static void responseToJson(HttpServletResponse response, Object obj) {

		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		response.setHeader("X-Frame-Options", "SAMEORIGIN");

		try {

			Gson gson = new Gson();
			response.getWriter().write(gson.toJson(obj));
			response.getWriter().flush();

		} catch (IOException e) {
			e.printStackTrace();

		}

	}


}
